﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FPSO.Models.Domain
{
    public class ShipDraught
    {
        public ShipDraught()
        {
            MidPDraft = 0d;
			MidSDraft = 0d;
			AftPDraft = 0d;
			AftSDraft = 0d;
			FwdPDraft = 0d;
			FwdSDraft = 0d;
			Heel = 0d;
            Trim = 0d;

			Disp = 0d;
			BallastW = 0d;
			CargoW = 0d;
			Lcg = 0d;
			Kmt = 0d;
			Gm = 0d;
		}

		public double Disp { get; set; }
		public double BallastW { get; set; }
		public double CargoW { get; set; }
		public double Lcg { get; set; }
		public double Kmt { get; set; }
		public double Gm { get; set; }
		/// <summary>
		/// 船舯吃水左舷
		/// </summary>
		public double MidPDraft { get; set; }
		/// <summary>
		/// 船舯吃水右舷
		/// </summary>
		public double MidSDraft { get; set; }
		/// <summary>
		/// 船艉吃水左舷
		/// </summary>
		public double AftPDraft { get; set; }
		/// <summary>
		/// 船艉吃水右舷
		/// </summary>
		public double AftSDraft { get; set; }
		/// <summary>
		/// 船艏吃水左舷
		/// </summary>
		public double FwdPDraft { get; set; }
		/// <summary>
		/// 船艏吃水右舷
		/// </summary>
		public double FwdSDraft { get; set; }
        /// <summary>
        /// 横倾
        /// </summary>
        public double Heel { get; set; }
        /// <summary>
        /// 纵倾
        /// </summary>
        public double Trim { get; set; }

		private double weight_check_limit = 5.0;
		private double length_check_limit = 0.01;
		public bool isEqual(ShipDraught newShipDraught)
		{
			bool check = true;
			if (Math.Abs(Disp - newShipDraught.Disp) > weight_check_limit
				|| Math.Abs(BallastW - newShipDraught.BallastW) > weight_check_limit
				|| Math.Abs(CargoW - newShipDraught.CargoW) > weight_check_limit)
				check = false;
			else if (Math.Abs(MidPDraft - newShipDraught.MidPDraft) > length_check_limit
				|| Math.Abs(MidSDraft - newShipDraught.MidSDraft) > length_check_limit
				|| Math.Abs(AftPDraft - newShipDraught.AftPDraft) > length_check_limit
				|| Math.Abs(AftSDraft - newShipDraught.AftSDraft) > length_check_limit
				|| Math.Abs(FwdPDraft - newShipDraught.FwdPDraft) > length_check_limit
				|| Math.Abs(FwdSDraft - newShipDraught.FwdSDraft) > length_check_limit)
				check = false;
			return check;
		}
    }

}
